//
//  SDAuthManager.h
//  SinoDetectionDemo
//
//  Created by DCN1266 on 2022/5/17.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/// 鉴权错误域
extern const NSString * const SDAMAuthErrorDomain;
/// 鉴权错误码
typedef NS_ENUM(NSInteger, SDAMAuthErrorCode) {
    /// AppKey不正确
    SDAMAuthErrorCodeWrongAppKey = 1080031007,
    
    /// Bundle Id不正确
    SDAMAuthErrorCodeWrongBundleId = 1080031010,
};

@interface SDAuthManager : NSObject

/// 是否已鉴权的
@property (nonatomic, assign, readonly) BOOL authed;

/// 是否上传数据
@property (nonatomic, assign, readonly) BOOL isUploadData;

/// 访问令牌
@property (nonatomic, strong, readonly) NSString *accessToken;

+ (instancetype)sharedAuthManager;

/// 鉴权
/// - Parameters:
///   - appKey: appKey
///   - appSecret: appSecret
///   - completion: completion
- (void)authWithAppKey:(NSString *)appKey appSecret:(NSString *)appSecret completion:(nullable void (^)(NSError * _Nullable error))completion;

/// 鉴权
/// @param appKey appKey
/// @param bundleId Bundle Id
- (void)authWithAppKey:(nonnull NSString *)appKey bundleId:(nonnull NSString *)bundleId DEPRECATED_MSG_ATTRIBUTE("请改用'authWithAppKey:appSecret:'方法");

@end

NS_ASSUME_NONNULL_END
